const Router=require("koa-router");
const APIRouter=new Router();
const axios=require("axios");


APIRouter.get("/songs",async(ctx,next)=>{
    const {pageNum=1,pageSize=30}=ctx.request.query;
    const albumData=await axios.get(`https://www.ximalaya.com/revision/play/album?albumId=9723091&pageNum=${pageNum}&sort=0&pageSize=${pageSize}`,{
        headers: {
            host: 'www.ximalaya.com',
            referer: 'https://www.ximalaya.com'
        }
    }).then(res=>res.data);
    ctx.body=albumData;
    await next();
});


module.exports=function(app){
    app.use(APIRouter.routes());
    app.use(APIRouter.allowedMethods());
}